<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:36:"./themes/admin/admin_user\index.html";i:1741049647;s:39:"D:\phpcode\dpwkt\themes\admin\base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">管理员管理</li>
                <li class=""><a href="<?php echo url('admin/admin_user/add'); ?>">添加管理员</a></li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layui-form-pane" action="<?php echo url('admin/admin_user/index'); ?>" method="get">
                        <div class="layui-form-item">
                            <label class="layui-form-label">部门</label>
                            <div class="layui-input-inline" >
                                <select name="did" lay-skin="select">
                                    <option value="">请选择部门</option>
                                    <?php if(is_array($department_list) || $department_list instanceof \think\Collection || $department_list instanceof \think\Paginator): if( count($department_list)==0 ) : echo "" ;else: foreach($department_list as $key=>$v): ?>
                                    <option value="<?php echo $v['id']; ?>" <?php if($did==$v['id']): ?> selected="selected"<?php endif; ?>><?php echo $v['title']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                            <label class="layui-form-label">权限组</label>
                            <div class="layui-input-inline" >
                                <select name="gid" lay-skin="select">
                                <option value="">请选择权限组</option>
                                <?php if(is_array($auth_group_list) || $auth_group_list instanceof \think\Collection || $auth_group_list instanceof \think\Paginator): if( count($auth_group_list)==0 ) : echo "" ;else: foreach($auth_group_list as $key=>$v): ?>
                                <option value="<?php echo $v['id']; ?>" <?php if($gid==$v['id']): ?> selected="selected"<?php endif; ?>><?php echo $v['title']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">关键词</label>
                            <div class="layui-input-inline">
                                <input type="text" name="keyword" value="<?php echo $keyword; ?>" placeholder="请输入关键词" class="layui-input">
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn">搜索</button>
                            </div>
                            <div class="layui-inline">
                                <a href="<?php echo url('admin/admin_user/index',['cleanup'=>'cleanup']); ?>" class="layui-btn layui-btn-danger">清除</a>
                            </div>
                        </div>
                    </form>
                    <hr>
                    <form class="layui-form" action="">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="width: 30px;">ID</th>
                                <th>部门</th>
                                <th>权限组</th>
                                <th>管理员名</th>
                                <th>姓名</th>
                                <th>手机</th>
                                <th>状态</th>
                                <th style="width: 130px;">创建时间</th>
                                <th style="width: 80px;">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if(is_array($admin_user_list) || $admin_user_list instanceof \think\Collection || $admin_user_list instanceof \think\Paginator): if( count($admin_user_list)==0 ) : echo "" ;else: foreach($admin_user_list as $key=>$vo): ?>
                            <tr>
                                <td><?php echo $vo['id']; ?></td>
                                <td><?php if($vo['did'] != null): ?><?php echo $vo['department']['title']; else: ?>总部门<?php endif; ?></td>
                                <td><?php echo $vo['title']; ?></td>
                                <td><?php echo $vo['username']; ?></td>
                                <td><?php echo $vo['name']; ?></td>
                                <td><?php echo $vo['mobile']; ?></td>
                                <td><input type="checkbox" name="status" lay-skin="switch" lay-filter="switchTest" value="<?php echo $vo['id']; ?>" lay-text="启用|禁用" <?php if($vo['status']==1): ?>checked<?php endif; ?>></td>
                                <td><?php echo $vo['create_time']; ?></td>
                                <td>
                                    <div class="layui-btn-group">
                                        <a href="<?php echo url('admin/admin_user/edit',['id'=>$vo['id']]); ?>" class="layui-btn layui-btn-sm" title="编辑"><i class="layui-icon">&#xe642;</i></a>
                                        <a href="<?php echo url('admin/admin_user/delete',['id'=>$vo['id']]); ?>" class="layui-btn layui-btn-sm ajax-delete" title="删除"><i class="layui-icon">&#xe640;</i></a>
                                    </div>
                                </td>
                            </tr>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                            </tbody>
                        </table>
                    </form>
                    <!--分页-->
                    <?php echo $admin_user->render(); ?>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['layer','form'], function(){ //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
        var form = layui.form;

        /**
         * 通用删除
         */
        $('.ajax-delete').on('click', function () {
            var _href = $(this).attr('href');
            layer.open({
                shade: false,
                content: '确定删除？',
                btn: ['确定', '取消'],
                yes: function (index) {
                    $.ajax({
                        url: _href,
                        type: "get",
                        success: function (info) {
                            if (info.code === 1) {
                                setTimeout(function () {
                                    location.href = info.url;
                                }, 1000);
                            }
                            layer.msg(info.msg);
                        }
                    });
                    layer.close(index);
                }
            });

            return false;
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            if(this.checked==true){
                var status=1;
            }else{
                var status=0;
            }
            $.ajax({
                url: "<?php echo url('admin/admin_user/update'); ?>?id="+this.value+"&status="+status,
                type: "get",
                success: function (info) {
                    setTimeout(function () {
                        location.href = info.url;
                    }, 1000);
                    layer.msg(info.msg);
                }
            });
            return false;
        });

    });
</script>

<!--页面JS脚本-->
</body>
</html>

